cmake_minimum_required(VERSION 3.20)

project(EasyCarUI VERSION 1.0)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

aux_source_directory(${PROJECT_SOURCE_DIR}/src SRC_FILES)
aux_source_directory(${PROJECT_SOURCE_DIR}/src/Model SRC_FILES)
aux_source_directory(${PROJECT_SOURCE_DIR}/src/Deps SRC_FILES)
aux_source_directory(${PROJECT_SOURCE_DIR}/src/Renderer SRC_FILES)
aux_source_directory(${PROJECT_SOURCE_DIR}/src/Renderer/Vulkan SRC_FILES)

include_directories(${PROJECT_SOURCE_DIR})
include_directories(${PROJECT_SOURCE_DIR}/src)

find_package(SDL3 REQUIRED CONFIG REQUIRED COMPONENTS SDL3-shared)
find_package(assimp REQUIRED CONFIG REQUIRED)


add_executable(EasyCarUI ${SRC_FILES})

target_link_libraries(EasyCarUI PRIVATE vulkan SDL3::SDL3 assimp)

install(TARGETS EasyCarUI
        DESTINATION bin)

install(DIRECTORY ${PROJECT_SOURCE_DIR}/shaders
        DESTINATION bin
        FILES_MATCHING PATTERN *.spv)

install(DIRECTORY ${PROJECT_SOURCE_DIR}/textures
        DESTINATION bin
        FILES_MATCHING PATTERN *.jpeg)

file(GLOB_RECURSE SPIRV_FILES ${PROJECT_SOURCE_DIR}/shaders/*.spv)
file(GLOB_RECURSE TEXTURE_FILES ${PROJECT_SOURCE_DIR}/textures/*.jpg)


file(GLOB SHADERS ${PROJECT_SOURCE_DIR}/shaders "*.spv")
add_custom_target(shaders
    DEPENDS ${SHADERS}
    COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/shaders
    COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/shaders ${CMAKE_CURRENT_BINARY_DIR}/shaders
)
add_dependencies(EasyCarUI shaders)

file(GLOB TEXTURES ${PROJECT_SOURCE_DIR}/textures "*.jpg")
add_custom_target(textures
    DEPENDS ${TEXTURES}
    COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/textures
    COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/textures ${CMAKE_CURRENT_BINARY_DIR}/textures
)
add_dependencies(EasyCarUI textures)


file(GLOB MODELS ${PROJECT_SOURCE_DIR}/Models "*.fbx")
add_custom_target(models
    DEPENDS ${MODELS}
    COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/Models
    COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/Models ${CMAKE_CURRENT_BINARY_DIR}/Models
    WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
)
add_dependencies(EasyCarUI models)